using System;

using CommonTypes.Math;

namespace CommonTypes.Math.Geometry3D
{
	public sealed class Transformation
	{
		public static Matrix4F RotateX(double angle)
		{
			float sin = (float)System.Math.Sin(angle);
			float cos = (float)System.Math.Cos(angle);

			return new Matrix4F(
				1,	0,	0,	 0,
				0,	cos,-sin,0,
				0,	sin, cos,0,
				0,	0,	 0,	 1);
		}
		public static Matrix4F RotateY(double angle)
		{
			float sin = (float)System.Math.Sin(angle);
			float cos = (float)System.Math.Cos(angle);

			return new Matrix4F(
				cos,	0,	sin,	0,
				0,		1,  0,		0,
				-sin,	0,  cos,	0,
				0,		0,	0,		1);
		}
		public static Matrix4F RotateZ(double angle)
		{
			float sin = (float)System.Math.Sin(angle);
			float cos = (float)System.Math.Cos(angle);

			return new Matrix4F(
				cos,	-sin,	0,	0,
				sin,	cos,	0,	0,
				0,		0,		1,	0,
				0,		0,		0,	1);
		}

        public static CommonTypes.Math.Matrix4F GetRotationMatrix(CommonTypes.Math.Vector3D angles)
        {
            CommonTypes.Math.Matrix4F matrixX = CommonTypes.Math.Geometry3D.Transformation.RotateX(CommonTypes.Geometry.DegToRad(angles.X));
            CommonTypes.Math.Matrix4F matrixY = CommonTypes.Math.Geometry3D.Transformation.RotateY(CommonTypes.Geometry.DegToRad(angles.Y));
            CommonTypes.Math.Matrix4F matrixZ = CommonTypes.Math.Geometry3D.Transformation.RotateZ(CommonTypes.Geometry.DegToRad(angles.Z));
            matrixX = matrixX * matrixY * matrixZ;
            return matrixX;
        }

		#region Private Constructor
		private Transformation()
		{}
		#endregion
	}
}
